<template>
	<view class="contents" :style="'height:'+screenHeight+'px'">
		<view class="situationbody">
			<view class=" header">
				<view class="imglist">
					
					<view class="imgcount">
						<span class="name">{{doctor.DptName}}</span>

					</view>
					<view class="imgright">
						<!-- <span v-show="!collect"><u-icon name="heart" color="red" size="50"
								@click="collects"></u-icon></span>
						<span v-show="collect"><u-icon name="heart-fill" color="red" size="50"
								@click="qxcollect"></u-icon></span> -->
						<!-- <span class="number">0次预约</span> -->
						
					</view>

				</view>

				<view class="buttons">
					{{doctor.Introduction}}
				</view>
			</view>

			<!-- <view class="conter">
				<view class="">
					<span class="tiao">|</span>
					<span class="title">擅长领域</span>
				</view>
				<view class="buttontext">
					{{doctor.ShortName}}
				</view>
			</view> -->

			<view class="Scheduling">
				<view class="">
					<span class="tiao">|</span>
					<span class="title">时段</span>
				</view>
				<view class="lists" v-for="(item,index) in datetime" :key="index">
					<view class="letftext">
						<view style="padding-left: 10px;">
							<span style="font-weight: bold;">{{item.TimeSpace}}</span>
						</view>
						
					</view>
					<view class="righttext">
						<span class="excessive bacnone2" @click="reservation(item.TimeSpace)">预约</span>
						<!-- <span class="excessive" style="background-color: gray;" v-show="item.resideNum==0">排满</span> -->
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				screenHeight: getApp().globalData.screenHeight-44,
				show: false,
				excessive:false,
				collect: false,
				doctor: [],
				datetime:[],
				sd:'',
				id:'',
				fullday:''
			}
		},
		onLoad: function(DptId) {
			uni.showLoading({
				title: '加载中'
			})
			let ogj=JSON.parse(DptId.objs)
			this.sd=ogj.sj
			this.id=ogj.DptId
			this.fullday=ogj.fullday
			this.getDutyId()

		},
		created() {

		},
		methods: {
			async getDutyId() {
				// let id=JSON.parse(DptId.DptId)
				console.log("sssssssssss",this.id)
				this.$request("DutyRecord", "Detail", {
					DepartmentId: this.id
				}).then(res => {
					if (res.code == 1) {
						uni.hideLoading();
						this.doctor = res.data
						this.getOnecollection()
						uni.hideLoading();
						// let item=res.data[0].SpaceList
						// for (let i=0;i<item.length;i++){
						// 	if(item[i].resideNum>0){
						// 		this.excessive=true
						// 		break
						// 	}
						// }
						// 	console.log("doctor", this.doctor)
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 2000,
						});
					}
				})
			},
			reservation(item) {

				// let doctorinfor = JSON.stringify(item)
				let doctors = {
					DptId:this.id,
					shijian: item,
					DptName: this.doctor.DptName,
					GHF: this.doctor.GHF,
					sd:this.sd,
					fullday:this.fullday
				}
				let doctlist = JSON.stringify(doctors)
				//console.log("1",doctlist)
				uni.navigateTo({
					url: `/pages/newblock/Visit/Visitkeshi?doctorinfor=${doctlist}`,
					fail(error) {
						console.log(error)
					}
				})
			},
			showToast(params) {
				this.$refs.uToast.show({
					...params,
					complete() {
						params.url && uni.navigateTo({
							url: params.url
						})
					}
				})
			},
			getOnecollection() {
				this.$request("DutyRecord", "TimeList", {
					companycode: '8170000'
				}).then(res => {
					console.log("shijian",res)
					this.datetime=res.data
				})
			},
			collects() {

			},
			qxcollect() {
				this.$request("Collection", "CancelCollection", {
					DoctorId: this.doctor.DoctorId
				}).then(res => {
					if (res.code == 1) {
						this.collect = false
						uni.showToast({
							title: "取消收藏",
							icon: "none",
							duration: 2000,
						});
					}
				})

			}
		}
	}
</script>

<style>
	@import './situation.css'
</style>